From affc26bdedba2cf9e862dbc9b2f3c50bc94372cd Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 23 Feb 2004 04:25:48 +0000 Subject: [PATCH] Add a type (with format output '1') to the '%' output. --- cetus.c | 1 + copilot.c | 1 + csv_util.c | 4 ++++ csv_util.h | 1 + defs.h | 10 ++++++++++ delgpl.c | 1 + easygps.c | 1 + garmin.c | 1 + gcdb.c | 1 + geo.c | 1 + geoniche.c | 1 + gpilots.c | 1 + gpsdrive.c | 1 + gpspilot.c | 1 + gpsutil.c | 1 + gpx.c | 1 + holux.c | 1 + internal_styles.c | 2 ++ magnav.c | 1 + magproto.c | 1 + mapopolis.c | 1 + mapsend.c | 1 + mapsource.c | 1 + navicache.c | 1 + nmea.c | 1 + ozi.c | 1 + pcx.c | 1 + psitrex.c | 1 + psp.c | 1 + quovadis.c | 1 + saroute.c | 1 + style/custom.style | 1 + style/tabsep.style | 1 + tiger.c | 1 + tmpro.c | 1 + tpg.c | 1 + vecs.c | 21 +++++++++++++++++++++ xcsv.c | 15 +++++++++++++++ 38 files changed, 85 insertions(+) diff --git a/cetus.c b/cetus.c index f8373521a..170dd8bf9 100644 --- a/cetus.c +++ b/cetus.c @@ -415,6 +415,7 @@ data_write(void) ff_vecs_t cetus_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/copilot.c b/copilot.c index 3ee51f824..44a55e0cb 100644 --- a/copilot.c +++ b/copilot.c @@ -192,6 +192,7 @@ data_write(void) ff_vecs_t copilot_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/csv_util.c b/csv_util.c index 85dd77ef2..c095d7e51 100644 --- a/csv_util.c +++ b/csv_util.c @@ -329,6 +329,10 @@ xcsv_file_init(void) */ xcsv_file.ofield = xcalloc(sizeof(queue), 1); QUEUE_INIT(xcsv_file.ofield); + /* + * Provide a sane default for CSV _files_. + */ + xcsv_file.type = ff_type_file; xcsv_file.mkshort_handle = mkshort_new_handle(); } diff --git a/csv_util.h b/csv_util.h index 7338fa8ba..197b58842 100644 --- a/csv_util.h +++ b/csv_util.h @@ -120,6 +120,7 @@ typedef struct { char * extension; /* preferred filename extension (for wrappers)*/ void * mkshort_handle; /* handle for mkshort() */ + ff_type type; /* format type for GUI wrappers. */ } xcsv_file_t; diff --git a/defs.h b/defs.h index 807b2362c..c78a7b56e 100644 --- a/defs.h +++ b/defs.h @@ -301,7 +301,17 @@ typedef struct arglist { long argtype; } arglist_t; +typedef enum { + ff_type_file = 1, /* normal format: useful to a GUI. */ + ff_type_internal, /* fmt not useful with default options */ + ff_type_serial, /* format describes a serial protoco (GUI can display port names) */ +} ff_type; + +/* + * Describe the file format to the caller. + */ typedef struct ff_vecs { + ff_type type; ff_init rd_init; ff_init wr_init; ff_deinit rd_deinit; diff --git a/delgpl.c b/delgpl.c index 7709e8259..73e1c6784 100644 --- a/delgpl.c +++ b/delgpl.c @@ -110,6 +110,7 @@ gpl_write(void) } ff_vecs_t gpl_vecs = { + ff_type_file, gpl_rd_init, gpl_wr_init, gpl_rd_deinit, diff --git a/easygps.c b/easygps.c index e028e052b..d568b2610 100644 --- a/easygps.c +++ b/easygps.c @@ -261,6 +261,7 @@ data_write(void) ff_vecs_t easygps_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/garmin.c b/garmin.c index f23f7075f..34babd697 100644 --- a/garmin.c +++ b/garmin.c @@ -560,6 +560,7 @@ data_write() ff_vecs_t garmin_vecs = { + ff_type_serial, rw_init, rw_init, rw_deinit, diff --git a/gcdb.c b/gcdb.c index a439e0ee6..b4bd3ac52 100644 --- a/gcdb.c +++ b/gcdb.c @@ -330,6 +330,7 @@ data_write(void) ff_vecs_t gcdb_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/geo.c b/geo.c index ffb0812ed..1f4425cb0 100644 --- a/geo.c +++ b/geo.c @@ -286,6 +286,7 @@ geo_write(void) } ff_vecs_t geo_vecs = { + ff_type_file, geo_rd_init, geo_wr_init, geo_rd_deinit, diff --git a/geoniche.c b/geoniche.c index 94cf48e8d..36f3901d2 100644 --- a/geoniche.c +++ b/geoniche.c @@ -524,6 +524,7 @@ data_write(void) ff_vecs_t geoniche_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/gpilots.c b/gpilots.c index 3e4c87428..b615fde99 100644 --- a/gpilots.c +++ b/gpilots.c @@ -304,6 +304,7 @@ data_write(void) ff_vecs_t gpilots_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/gpsdrive.c b/gpsdrive.c index b6dd6262d..51bd73d15 100644 --- a/gpsdrive.c +++ b/gpsdrive.c @@ -196,6 +196,7 @@ data_write(void) } ff_vecs_t gpsdrive_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/gpspilot.c b/gpspilot.c index 8502cb189..36f4ec071 100644 --- a/gpspilot.c +++ b/gpspilot.c @@ -246,6 +246,7 @@ data_write(void) ff_vecs_t gpspilot_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/gpsutil.c b/gpsutil.c index 081a8435c..c8d5ae85a 100644 --- a/gpsutil.c +++ b/gpsutil.c @@ -121,6 +121,7 @@ data_write(void) ff_vecs_t gpsutil_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/gpx.c b/gpx.c index eba8bf775..5b137c4d0 100644 --- a/gpx.c +++ b/gpx.c @@ -1214,6 +1214,7 @@ arglist_t gpx_args[] = { }; ff_vecs_t gpx_vecs = { + ff_type_file, gpx_rd_init, gpx_wr_init, gpx_rd_deinit, diff --git a/holux.c b/holux.c index eb6e4baf2..41735b2d4 100644 --- a/holux.c +++ b/holux.c @@ -290,6 +290,7 @@ static void data_write(void) ff_vecs_t holux_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/internal_styles.c b/internal_styles.c index 6c52443d6..2cc2ddee1 100644 --- a/internal_styles.c +++ b/internal_styles.c @@ -65,6 +65,7 @@ static char custom[] = "FIELD_DELIMITER COMMA\n" "RECORD_DELIMITER NEWLINE\n" "BADCHARS COMMA\n" +"FORMAT_TYPE INTERNAL\n" "#\n" "# HEADER STUFF:\n" @@ -458,6 +459,7 @@ static char tabsep[] = "FIELD_DELIMITER TAB\n" "RECORD_DELIMITER NEWLINE\n" "BADCHARS TAB\n" +"FORMAT_TYPE INTERNAL\n" "#\n" "# INDIVIDUAL DATA FIELDS:\n" diff --git a/magnav.c b/magnav.c index a8449bb05..e84837437 100644 --- a/magnav.c +++ b/magnav.c @@ -262,6 +262,7 @@ data_write(void) ff_vecs_t magnav_vec = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/magproto.c b/magproto.c index c0f099452..79738bab9 100644 --- a/magproto.c +++ b/magproto.c @@ -1343,6 +1343,7 @@ mag_write(void) } ff_vecs_t mag_vecs = { + ff_type_serial, mag_rd_init, mag_wr_init, mag_deinit, diff --git a/mapopolis.c b/mapopolis.c index 6b6178c5f..ebc8bd83f 100644 --- a/mapopolis.c +++ b/mapopolis.c @@ -310,6 +310,7 @@ data_write(void) ff_vecs_t mapopolis_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/mapsend.c b/mapsend.c index 1feecd5e8..449dc4f71 100644 --- a/mapsend.c +++ b/mapsend.c @@ -583,6 +583,7 @@ mapsend_wpt_write(void) ff_vecs_t mapsend_vecs = { + ff_type_file, mapsend_rd_init, mapsend_wr_init, mapsend_rd_deinit, diff --git a/mapsource.c b/mapsource.c index dbd9b3af3..9cff4672b 100644 --- a/mapsource.c +++ b/mapsource.c @@ -1981,6 +1981,7 @@ mps_write(void) } ff_vecs_t mps_vecs = { + ff_type_file, mps_rd_init, mps_wr_init, mps_rd_deinit, diff --git a/navicache.c b/navicache.c index 91a04b8f6..e42bbb6e9 100644 --- a/navicache.c +++ b/navicache.c @@ -205,6 +205,7 @@ nav_write(void) } ff_vecs_t navicache_vecs = { + ff_type_file, nav_rd_init, nav_wr_init, nav_rd_deinit, diff --git a/nmea.c b/nmea.c index 38f96cca9..6bab42a96 100644 --- a/nmea.c +++ b/nmea.c @@ -317,6 +317,7 @@ nmea_write() } ff_vecs_t nmea_vecs = { + ff_type_file, nmea_rd_init, nmea_wr_init, nmea_rd_deinit, diff --git a/ozi.c b/ozi.c index 7474520c6..3de14fa1b 100644 --- a/ozi.c +++ b/ozi.c @@ -691,6 +691,7 @@ data_write(void) } ff_vecs_t ozi_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/pcx.c b/pcx.c index 3731c33b9..974c63bd4 100644 --- a/pcx.c +++ b/pcx.c @@ -166,6 +166,7 @@ fprintf(file_out, ff_vecs_t pcx_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/psitrex.c b/psitrex.c index 7a848a8a0..fe55b6c5e 100755 --- a/psitrex.c +++ b/psitrex.c @@ -797,6 +797,7 @@ psit_write(void) } ff_vecs_t psit_vecs = { + ff_type_file, psit_rd_init, psit_wr_init, psit_rd_deinit, diff --git a/psp.c b/psp.c index ee009b621..01fde6645 100644 --- a/psp.c +++ b/psp.c @@ -458,6 +458,7 @@ psp_write(void) } ff_vecs_t psp_vecs = { + ff_type_file, psp_rd_init, psp_wr_init, psp_rd_deinit, diff --git a/quovadis.c b/quovadis.c index c49149b1e..bf8796d3d 100644 --- a/quovadis.c +++ b/quovadis.c @@ -284,6 +284,7 @@ data_write(void) ff_vecs_t quovadis_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/saroute.c b/saroute.c index a4725ef54..d5cdfdbd6 100644 --- a/saroute.c +++ b/saroute.c @@ -235,6 +235,7 @@ wr_init(const char *fname) } ff_vecs_t saroute_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/style/custom.style b/style/custom.style index 1c871cb06..d3776aaf1 100644 --- a/style/custom.style +++ b/style/custom.style @@ -13,6 +13,7 @@ DESCRIPTION Custom "Everything" Style FIELD_DELIMITER COMMA RECORD_DELIMITER NEWLINE BADCHARS COMMA +FORMAT_TYPE INTERNAL # # HEADER STUFF: diff --git a/style/tabsep.style b/style/tabsep.style index 1f75d7ddc..af9efd4b4 100644 --- a/style/tabsep.style +++ b/style/tabsep.style @@ -19,6 +19,7 @@ DESCRIPTION All database fields on one tab-separated line FIELD_DELIMITER TAB RECORD_DELIMITER NEWLINE BADCHARS TAB +FORMAT_TYPE INTERNAL # # INDIVIDUAL DATA FIELDS: diff --git a/tiger.c b/tiger.c index 865b5d7a5..312fa0e7d 100644 --- a/tiger.c +++ b/tiger.c @@ -272,6 +272,7 @@ data_write(void) ff_vecs_t tiger_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/tmpro.c b/tmpro.c index 875e009f3..e9968814d 100644 --- a/tmpro.c +++ b/tmpro.c @@ -243,6 +243,7 @@ data_write(void) } ff_vecs_t tmpro_vecs = { + ff_type_file, rd_init, wr_init, rd_deinit, diff --git a/tpg.c b/tpg.c index 226ff7d03..f8766f423 100644 --- a/tpg.c +++ b/tpg.c @@ -334,6 +334,7 @@ tpg_write(void) } ff_vecs_t tpg_vecs = { + ff_type_file, tpg_rd_init, tpg_wr_init, tpg_rd_deinit, diff --git a/vecs.c b/vecs.c index 23258201e..de7a670af 100644 --- a/vecs.c +++ b/vecs.c @@ -404,6 +404,22 @@ disp_vecs(void) } } +/* + * Additional information for V1. + * Output format type at front of line. + */ +disp_v1(ff_type t) +{ + char *tstring; + + switch (t) { + case ff_type_file: tstring = "file"; break; + case ff_type_serial: tstring = "serial"; break; + case ff_type_internal: tstring = "internal"; break; + default: tstring = "unknown"; break; + } + printf("%s\t", tstring); +} /* * Display the available formats in a format that's easy to machine * parse. Typically invoked by programs like graphical wrappers to @@ -417,13 +433,18 @@ disp_formats(int version) switch(version) { case 0: + case 1: for (vec = vec_list; vec->vec; vec++) { + if (version > 0) + disp_v1(vec->vec->type); printf("%s\t%s\t%s\n", vec->name, vec->extension? vec->extension : "", vec->desc); } for (svec = style_list; svec->name; svec++) { xcsv_read_internal_style(svec->style_buf); + if (version > 0) + disp_v1(xcsv_file.type); printf("%s\t%s\t%s\n", svec->name, xcsv_file.extension ? xcsv_file.extension : "", xcsv_file.description); } diff --git a/xcsv.c b/xcsv.c index 37a9f58e0..116dd53a3 100644 --- a/xcsv.c +++ b/xcsv.c @@ -251,6 +251,20 @@ xcsv_parse_style_line(const char *sbuff) } else + if (ISSTOKEN(sbuff, "FORMAT_TYPE")) { + const char *p; + for (p = &sbuff[11]; *p && isspace(*p); p++) { + ; + } + if (ISSTOKEN(p, "INTERNAL")) { + xcsv_file.type = ff_type_internal; + } + /* this is almost inconcievable... */ + if (ISSTOKEN(p, "SERIAL")) { + xcsv_file.type = ff_type_serial; + } + } else + if (ISSTOKEN(sbuff, "DESCRIPTION")) { xcsv_file.description = csv_stringtrim(&sbuff[11],"", 0); } else @@ -521,6 +535,7 @@ xcsv_wr_deinit(void) } ff_vecs_t xcsv_vecs = { + ff_type_internal, xcsv_rd_init, xcsv_wr_init, xcsv_rd_deinit, -- 2.30.2